package engine.graphics.resources
{
	import flash.display.*;
	import flash.display3D.*;
	import flash.display3D.textures.*;
	
	public class RxGPUTexture2D extends RxGPUResource
	{
		private var m_texture:Texture;
		private var m_width:uint;
		private var m_height:uint;
		private var m_format:String;
		
		public function RxGPUTexture2D()
		{
			this.m_texture = null;
			this.m_width = 0;
			this.m_height = 0;
			this.m_format = null;
		}
		
		public function AddRef() : uint
		{
			this.m_refCount = this.m_refCount + 1;
			return this.m_refCount;
		}
		
		public function Create(param1:Context3D, param2:uint, param3:uint, param4:String, param5:Boolean) : Boolean
		{
			if (this.m_texture != null)
			{
				return false;
			}
			if (param1 == null)
			{
				return false;
			}
			this.m_texture = param1.createTexture(param2, param3, param4, param5);
			this.m_width = param2;
			this.m_height = param3;
			this.m_format = param4;
			
			return true;
		}
		
		public function CreateFromBitmapData(param1:Context3D, param2:BitmapData) : Boolean
		{
			if (this.m_texture != null)
			{
				return false;
			}
			if (param1 == null || param2 == null)
			{
				return false;
			}
			this.m_texture = param1.createTexture(param2.width, param2.height, Context3DTextureFormat.BGRA, false);
			if (this.m_texture == null)
			{
				return false;
			}
			this.m_texture.uploadFromBitmapData(param2, 0);
			this.m_width = param2.width;
			this.m_height = param2.height;
			this.m_format = Context3DTextureFormat.BGRA;
			return true;
		}
		
		public function GetTexture() : Texture
		{
			return this.m_texture;
		}
	}
}